<?php echo $this->render('frontend_common/header.phtml'); ?>
<?php $this->headLink()->appendStylesheet($this->baseUrl('css/admintable.css')); ?>
<div id="Content">
<div style="margin-left: 20px">
<table style="width:960px; margin-top: 30px;margin-right: 20px">
	<thead>
		<tr>
			<th class="idfirstcolumn">Mã số</th>
			<th>Tên khách hàng</th>
			<th>Username</th>
			<th>Trạng thái</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
<?php
	$active_img_url = $this->baseurl('images/system/active.png');
	$locked_img_url = $this->baseurl('images/system/locked-icon.png');
	$notactive_img_url = $this->baseurl('images/system/disable.png');
	
	foreach ($this->khachhang as $key=>$motkhachhang)
	{	
?>
	
		<tr 
		<?php
			if ($key % 2 != 0)
				echo ('class="changecolor1" style="background-color:#f3f3f3;"');
			else
				echo ('class="changecolor2" style="background-color:#FFF;"');
		?>>
			<td class="idfirstcolumn"><?php echo $motkhachhang->id ?>  </td>
			<td><?php echo $motkhachhang->tenkh ?>  </td>
			<td> <?php echo $motkhachhang->username ?> </td>
			<td>
			<?php 
				if($motkhachhang->trangthai==0)//Chưa kích hoạt
					echo '<img src="'.$notactive_img_url.'" alt="actived icon" title="Chưa kích hoạt"/>';
				elseif($motkhachhang->trangthai==1)//Đã bị khóa
					echo '<img src="'.$locked_img_url.'" alt="actived icon" title="Đang khóa" width="30px" height="30px"/>';
				elseif($motkhachhang->trangthai==2)//Đã kích hoạt
					echo '<img src="'.$active_img_url.'" alt="actived icon" title="Đã kích hoạt"/>';
				else
					echo "Không xác định";
			?>
			</td>
			<td class="command">
				<a class="command" href="<?php echo $this->url(array('controller'=>'admin','action'=>'customerdetail','id_kh'=>$motkhachhang->id)); ?>">
					Chi tiết</a>
					<?php 
						if($motkhachhang['role']!=1){
							if($motkhachhang['trangthai']==2){//Đã kích hoạt
					?>
								<a class="command" href="<?php echo $this->url(array('controller'=>'admin','action'=>'setsatecustomer','id_kh'=>$motkhachhang->id)); ?>">Khóa tài khoản</a>
					<?php
							}
						elseif($motkhachhang['trangthai']==1)//Đang khóa
						{
							?> 
							<a href="<?php echo $this->url(array('controller'=>'admin','action'=>'setsatecustomer','id_kh'=>$motkhachhang->id)); ?>">Mở tài khoản</a>
					<?php } } ?>
			</td>
		</tr>
<?php 
	}
?>
	</tbody>
</table>
<a style="border: 1px solid red; background-color: white; border-radius:5px 5px 5px; padding:5px ;font-weight: bold;color: black;text-decoration: none; margin-top: 30px; float: left;margin-bottom: 30px " href="<?php echo $this->baseUrl('admin/index') ?>">Admin page</a>
<?php echo $this->render('frontend_common/footer.phtml'); ?>